/*
 *  $Id: CheckVersion.cs 1217 2010-11-27 10:48:54Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2010 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using Nereal.Serialization;

namespace Ragima.Events {
    [TypeId("version")]
    public class CheckVersion : DirectConnectEvent {
        [Serialize, XmlName("version")]
        private string _version;

        public CheckVersion() {
            _version = Application.GetCurrentVersion();
        }

        protected override void ExecuteInner(DirectConnectScene scene) {
            var version = Application.GetCurrentVersion();
            if (version == _version) {
                scene.Log.Add(Resources.DirectConnect.CheckVersionComplete);
                scene.Mode.SendEvent(new SetRemotePlayer(scene.Mode.Player1));
            } else {
                scene.Log.Add(Resources.DirectConnect.CheckVersionError, version, _version);
                scene.Mode.DisconnectGame();
            }
        }
    }
}
